/* ************************************************************************

   Copyright:

   License:

   Authors:

************************************************************************ */

/* ************************************************************************



************************************************************************ */

/**
* This class represents a mapscript mapObj class.
*
*/
qx.Class.define("mmclient.mapscript.MapObj",
{
  extend : qx.core.Object,


  /*
  *****************************************************************************
     CONSTRUCTOR
  *****************************************************************************
  */

  construct : function() {
    qx.core.Object.call(this);
  },


  /*
  *****************************************************************************
     PROPERTIES
  *****************************************************************************
  */

  properties :
  {
    /**
    * Array of available layers (LayerObj).
    *
    */
    layerObjList :
    {
      check : "Array",
      init : null
    },

    /**
    * Image width
    *
    */
    width :
    {
      check : "Number",
      init : 0
    },

    /**
    * Image height
    *
    */
    height :
    {
      check : "Number",
      init : 0
    },

    /**
    * Pixel size in map units.
    *
    */
    cellSize :
    {
      check : "Number",
      init : 0
    },

    /**
    * MS_TRUE or MS_FALSE.
    *
    */
    debug :
    {
      check : "Boolean",
      init : false
    },

    /**
    * Stores extent values
    *
    */
    extent :
    {
      check : "Object",
      init: null
    },

    /**
    * The map's defined fonts.
    *
    */
    fontSet :
    {
      check : "Object",
      init : null
    },

    /**
    * Map background color.
    *
    */
    imageColor :
    {
      check : "Object",
      init : null
    },

    /**
    * Current output format type.
    *
    */
    imageType :
    {
      check : "String",
      init : "PNG"
    },

    /**
    * LegendObj - Reference to map's legend.
    *
    */
    legend :
    {
      check : "Object",
      init : null
    },

    /**
    * Filesystem path to mapfile.
    *
    */
    mapPath :
    {
      check : "String",
      init : ""
    },

    /**
    * Unique identifier.
    *
    */
    name :
    {
      check : "String",
      init : ""
    },

    /**
    * Number of map layers.
    *
    */
    numLayers :
    {
      check : "Number",
      init : 0
    },

    /**
    * Number of output formats.
    *
    */
    numOutputFormats :
    {
      check : "Number",
      init : 1
    },

    /**
    * Currently selected output format - Use selectOutputFormat() to select named output formats.
    *
    */
    outputFormat :
    {
      check : "Object",
      init : null
    },

    /**
    * Array of the available output formats.
    *
    */
    outputFormatList :
    {
      check : "Array",
      init : null
    },

    /**
    * Query map.
    *
    */
    queryMap :
    {
      check : "Object",
      init : null
    },

    /**
    * Reference map.
    *
    */
    referenceMap :
    {
      check : "Object",
      init : null
    },

    /**
    * Nominal DPI resolution. Default is 72.
    *
    */
    resolution :
    {
      check : "Number",
      init : 96
    },

    /**
    * The nominal map scale. A value of 25000 means 1:25000 scale.
    *
    */
    scale :
    {
      check : "Number",
      init : 0
    },

    /**
    * Reference to the scale bar.
    *
    */
    scaleBar :
    {
      check : "Object",
      init : null
    },

    /**
    * Base filesystem path to layer data.
    *
    */
    shapePath :
    {
      check : "String",
      init : ""
    },

    /**
    * MS_OFF, MS_ON, or MS_DEFAULT.
    *
    */
    status :
    {
      check : "Number",
      init : 0
    },

    /**
    * The map's set of symbols.
    *
    */
    symbolSet :
    {
      check : "Object",
      init : null
    },

    /**
    * MS_DD, MS_METERS, etc.
    *
    */
    units :
    {
      check : "Number",
      init : 0
    },


    /**
    * Reference to map's web definitions.
    *
    */
    web :
    {
      check : "Object",
      init : null
    },

    // Add-on Properties that are set/get Methods in the original MapScript
    /**
    * Set or Get map projection (to / from) PROJ.4 definition string proj4.
    *
    */
    projection :
    {
      check : "String",
      init : ""
    }
  },


  /*
  *****************************************************************************
     MEMBERS
  *****************************************************************************
  */

  members :
  {
    /**
     * Sets the map image size.
     *
     * @type member
     * @param width {Integer} Image Width.
     * @param height {Integer} Image Height.
     * @return {void} 
     */
    setSize : function(width, height)
    {
      this.setWidth(width);
      this.setHeight(height);
    },

    /**
     * Changes the map's extent using minX, minY, maxX, maxY coordinates.
     *
     * @type member
     * @param minx {Float} Minimum X.
     * @param miny {Float} Minimum Y.
     * @param maxx {Float} Maximum X.
     * @param maxy {Float} Maximum Y.
     * @return {void} 
     */
    changeExtent : function(minx, miny, maxx, maxy)
    {
      if (this.getExtent() == null) {
        this.setExtent(new mmclient.mapscript.RectObj);
      }

      this.getExtent().setMinX(minx);
      this.getExtent().setMinY(miny);
      this.getExtent().setMaxX(maxx);
      this.getExtent().setMaxY(maxy);
    }
  }
});
